package com.fengwk.resource.face.model;

import java.util.List;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.TransportException;

import com.fengwk.resource.face.entity.ResServer;
import com.fengwk.support.util.JGitUtils;

public class GitServer extends ResServer {
	
	private static final long serialVersionUID = 6945441860633908584L;
	
	private volatile Git git;
	
	public Git getGit() {
		return git;
	}

	public void setGit(Git git) {
		this.git = git;
	}
	
	/**
	 * 存储到git服务器中
	 * 
	 * @param paths
	 * @throws GitAPIException 
	 * @throws TransportException 
	 * @throws InvalidRemoteException 
	 * @throws InterruptedException 
	 */
	public synchronized void save(List<String> paths) throws InvalidRemoteException, TransportException, GitAPIException, InterruptedException {
		JGitUtils.commit(git, paths, null, null, null);
		JGitUtils.push(git, url, username, password);
	}
	
}
